//
//  XJLogViewController.m
//  MetalEquipUnion
//
//  Created by tangbin on 2021/10/21.
//

#import "XJLogViewController.h"
#import "TYZLogManager.h"

@interface XJLogViewController ()
@property (nonatomic, strong) UITextView *logTextView;
@end

@implementation XJLogViewController

- (void)dealloc
{
    debugMethod();
}

- (void)initWithVar
{
    [super initWithVar];
}

- (void)initWithNavBar
{
    [super initWithNavBar];
    
    [self initWithBackButton];
    
    self.navigationItem.title = @"日志";
    
    UIButton *btnRight = [EDSUtility createNavBtnRight:@"清除" titleColor:kThemeColor action:@selector(actionClear:) targetId:self];
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:btnRight];
    self.navigationItem.rightBarButtonItem = rightItem;
}

- (void)initWithSubView
{
    [super initWithSubView];
    
    [self initWithLogTextView];
}

- (void)initWithLogTextView
{
    CGRect frame = CGRectMake(0, 0, kScreenW, kScreenH - NAVBAR_HEIGHT_STATUS);
    
    _logTextView = [[UITextView alloc] initWithFrame:frame];
    _logTextView.font = FONTSIZE(16);
//    _logTextView.backgroundColor = [UIColor orangeColor];
    _logTextView.editable = NO;
    [self.view addSubview:_logTextView];
    
    NSString *log = [[TYZLogManager sharedInstance] readLog];
    _logTextView.text = log;
}

- (void)actionClear:(id)sender
{
    [[TYZLogManager sharedInstance] clearAllLog];
    
    _logTextView.text = [[TYZLogManager sharedInstance] readLog];
}

@end
